
import 'package:flutter/material.dart';
import 'package:reabampos/src/reabam/utils/rb_widget.dart';
import 'package:xsdk_flutter/xsdk/xsdk_flutter_package.dart';
//import 'package:mobile_scanner/mobile_scanner.dart';



/*
扫描条码二维码
 */
class ScanQrCodeStatePage extends XPageScan2State{

  String? sword;

  ScanQrCodeStatePage();

  @override
  Widget getItemWidgetInStack() {
    return XWidgetUtils.getLayoutPadding(padding: XWidgetUtils.getEdgeInsets(0, 0, 0, 0));
  }


  @override
  void scanResultCallback(String? result) {
    //XLogUtils.printLog('---result=$result');
    if(!XStringUtils.isEmpty(result)){
      XFlutterUtils.finishPage(context,result:result);
    }

  }

  @override
  void onStart() {
    setXTitle(
      titleText: '扫描',
      backgroundColor: XColorUtils.color000000,
      isShowBottomDivider:false,
      titleBarLeftWidgetColor: XColorUtils.colorFFFFFF,
      titleBarTitleTextColor: XColorUtils.colorFFFFFF,
    );

    Widget searchbarWidget = RBWidgets.getSearchBarWidget(
        initSearchValue: sword,
        rightCustomWidgetType: 0,
        outSideBackgroundColor:Colors.black,
        iconColor:XColorUtils.colorCCCCCC,
        textColor:Colors.white,
        searchBarBackgroundColor:XColorUtils.color666666,
        hintTextColor:XColorUtils.colorCCCCCC,
        hintText: '请输入搜索内容',
        onTapRightCustomIcon: () {
        },
        searchResultCallback: (String? result) {
          //记录返回当前搜索内容
          sword = result;
        },
        onTapSearch: (String? item) {
          //点击搜索
          scanResultCallback(sword);
        });

    setXTopBarWidget(
        height: 48, child: searchbarWidget, backgroundColor: Colors.black);
  }


}